




/*
'===============================================================================
'  LinqHelper.DAO.PhotosBase
'===============================================================================
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Data.Linq;
using LinqHelper;
using LinqHelper.Entity;
using LinqHelper.DAO;

namespace LinqHelper.DAO
{
	public class LqPhotosBase
	{
		public LqProvider provider = new LqProvider();
		
		/// <summary>
		/// Purpose: Class constructor.
		/// </summary>
		public LqPhotosBase()
		{
			// Nothing for now.
		}
		
		public void Insert(LqPhotosEntity obj)
		{
			provider.GetTable<LqPhotosEntity>().InsertOnSubmit(obj);
            provider.SubmitChanges();
		}

		public void Update(LqPhotosEntity _obj)
		{
			var q = from obj in provider.GetTable<LqPhotosEntity>()
                    where obj.Id == _obj.Id
                    select obj;
			LqPhotosEntity tmp = q.First<LqPhotosEntity>();
			
			tmp.PhotoPath = _obj.PhotoPath;
			tmp.FileType = _obj.FileType;
			tmp.CreatedDate = _obj.CreatedDate;
			provider.SubmitChanges();
		}
		
		public void Delete(LqPhotosEntity obj)
		{
			provider.GetTable<LqPhotosEntity>().DeleteOnSubmit(obj);
            provider.SubmitChanges();
		}
		
		
		public void DeleteById(Guid Id)
		{
			var q = from obj in provider.GetTable<LqPhotosEntity>()
                    where obj.Id == Id
                    select obj;
					
            LqPhotosEntity ob = (LqPhotosEntity)q.First<LqPhotosEntity>();
            provider.GetTable<LqPhotosEntity>().DeleteOnSubmit(ob);
            provider.SubmitChanges();
		}
		
		
		public void DeleteByPhotoPath(string PhotoPath)
		{
			var q = from obj in provider.GetTable<LqPhotosEntity>()
                    where obj.PhotoPath == PhotoPath
                    select obj;
					
            LqPhotosEntity ob = (LqPhotosEntity)q.First<LqPhotosEntity>();
            provider.GetTable<LqPhotosEntity>().DeleteOnSubmit(ob);
            provider.SubmitChanges();
		}
		
		
		public void DeleteByFileType(string FileType)
		{
			var q = from obj in provider.GetTable<LqPhotosEntity>()
                    where obj.FileType == FileType
                    select obj;
					
            LqPhotosEntity ob = (LqPhotosEntity)q.First<LqPhotosEntity>();
            provider.GetTable<LqPhotosEntity>().DeleteOnSubmit(ob);
            provider.SubmitChanges();
		}
		
		
		public void DeleteByCreatedDate(DateTime CreatedDate)
		{
			var q = from obj in provider.GetTable<LqPhotosEntity>()
                    where obj.CreatedDate == CreatedDate
                    select obj;
					
            LqPhotosEntity ob = (LqPhotosEntity)q.First<LqPhotosEntity>();
            provider.GetTable<LqPhotosEntity>().DeleteOnSubmit(ob);
            provider.SubmitChanges();
		}
		
		
		public LqPhotosEntity SelectOne(Guid Id)
		{
			var query = from obj in provider.GetTable<LqPhotosEntity>()
                        where obj.Id == Id
                        select obj;
            return query.First<LqPhotosEntity>();
		}

		public List<LqPhotosEntity> SelectAll()
		{
			var query = from obj in provider.GetTable<LqPhotosEntity>()
                        select obj;
            return query.ToList<LqPhotosEntity>();
		}
		
		
		public List<LqPhotosEntity> SelectById(Guid Id)
		{
			var query = from obj in provider.GetTable<LqPhotosEntity>()
                        where obj.Id == Id
                        select obj;
            return query.ToList<LqPhotosEntity>();
		}
		
		
		public List<LqPhotosEntity> SelectByPhotoPath(string PhotoPath)
		{
			var query = from obj in provider.GetTable<LqPhotosEntity>()
                        where obj.PhotoPath == PhotoPath
                        select obj;
            return query.ToList<LqPhotosEntity>();
		}
		
		
		public List<LqPhotosEntity> SelectByFileType(string FileType)
		{
			var query = from obj in provider.GetTable<LqPhotosEntity>()
                        where obj.FileType == FileType
                        select obj;
            return query.ToList<LqPhotosEntity>();
		}
		
		
		public List<LqPhotosEntity> SelectByCreatedDate(DateTime CreatedDate)
		{
			var query = from obj in provider.GetTable<LqPhotosEntity>()
                        where obj.CreatedDate == CreatedDate
                        select obj;
            return query.ToList<LqPhotosEntity>();
		}
		
		
		

	}
}
